package com.mySampleApplication.client.components;
import com.mySampleApplication.client.codeRule.CodeRule;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;

import java.util.Map;

public class SLayout extends VLayout {
    public SLayout() {
        // 创建一个垂直布局容器
        VLayout layout = new VLayout(10); // 参数15为布局成员之间的间距
        layout.setWidth100();
        layout.setHeight100();
        layout.setPadding(10);
        DataSource dataSource = SDataSource.getDataSource();

        Map<String, Object> listMap = CodeRule.getListGrid();
        ListGrid listGrid = (ListGrid) listMap.get("listGrid");
        listGrid.setData();
        // 设置数据源到列表网格
        listGrid.setDataSource(dataSource);
        // 加载数据
        listGrid.fetchData();

        DynamicForm filterForm = SFilterForm.getFilterForm(dataSource,listGrid);

        HLayout hLayout = SFilterForm.getSerchButton(listGrid, filterForm);

        layout.addMember(filterForm);
        layout.addMember(hLayout);
        // 组装页面
        //layout.addMember(searchArea);
        layout.addMember((HLayout)listMap.get("buttonLayout"));
        // 添加列表网格到布局容器中
        layout.addMember(listGrid);

        // 添加布局容器到页面中
        this.addChild(layout);


    }
}
